#ifndef _V_IF_RUNTIMEENV_INCLUDED_
#define _V_IF_RUNTIMEENV_INCLUDED_

#include "sys/IInterface.h"
#include "CoreDataID.h"

interface ITransaction;

delegate Delegate<void(objectid,IObject*)> ObjectCreatedEventHandler;
delegate Delegate<void(objectid,IObject*)> ObjectModifyingEventHandler;
delegate Delegate<void(objectid,IObject*)> ObjectModifiedEventHandler;
delegate Delegate<void(objectid,IObject*)> ObjectDeletingEventHandler;
delegate Delegate<void(objectid)> ObjectDeletedEventHandler;

interface IConnection : public IInterface
{
	DEFINE_IID(IID_RuntimeEnv)

	event_declare(ObjectCreatedEventHandler,ObjectCreated)
	event_declare(ObjectModifyingEventHandler,ObjectModifying)
	event_declare(ObjectModifiedEventHandler,ObjectModified)
	event_declare(ObjectDeletingEventHandler,ObjectDeleting)
	event_declare(ObjectDeletedEventHandler,ObjectDeleted)

	virtual IObject* FindParent(objectid child) = 0;
	virtual vresult CreateChild(objectid parent,vclsid childclsid,objectid* pobjectid) = 0;
	virtual vresult CreateChild(objectid parent,vclsid childclsid,IObject** ppchild) = 0;
	virtual vresult CreateWeakReference(objectid one,objectid another) = 0;
	virtual vresult CreateShareReference(objectid one,objectid shared) = 0;
	virtual uint32 GetChildrenCount(objectid object) const = 0;
	virtual uint32 GetWeakWeakReferencesCount(objectid object) const = 0;
	virtual uint32 GetShareReferencesCount(objectid object) const = 0;
	virtual uint32 FindChildren(objectid object,objectidarray& children) const = 0;
	virtual IObject* FindChild(objectid object,const String& name) const = 0;
	virtual uint32 FindWeakWeakReferences(objectid object,objectidarray& weakrefs) const = 0;
	virtual uint32 FindShareReferences(objectid object,objectidarray& sharerefs) const = 0;

	virtual vresult CreateObject(vclsid clsID,IObject** ppobject) = 0;

	virtual vresult CreateObject(vclsid clsID,objectid* pObjID)=0;
	virtual vresult CreateObjectAt(vclsid clsID,objectid objID)=0;
	virtual vresult CreateObjectAt(vclsid clsID,objectid objID,IObject** pObject)=0;
	virtual vresult CreateDummyObject(objectid* pObjID)=0;
	virtual vresult ReleaseObject(objectid oid)=0;
	virtual void ReleaseObject(const objectidarray& arrObjID)=0;
	virtual vresult DirectReleaseObject(objectid oid) = 0;

	virtual vresult QueryVInterface(objectid oid,viid iid,IInterface** ppInterface)=0;
	virtual bool IsValidObjectId(objectid oid)const=0;
	virtual vclsid GetClassID(objectid oid)=0;
	virtual IObject* FindObject(objectid oid) const= 0;

	virtual void PutIntoRecycleBin(objectid oid)=0;
	virtual void ClearRecycleBin()=0;
	virtual vresult ReleaseReservedNode() = 0;

	virtual ITransaction* GetTransaction()  const = 0;
};
#endif
